﻿/*
-----------------------------------
    Rodeo Game Engine

    Rodeo Core Module
    TextureManager.h - header file

    Copyright(c) Marcin Goryca
-----------------------------------
*/
#ifndef RODEO_CORE_TEXTUREMANAGER_H_
#define RODEO_CORE_TEXTUREMANAGER_H_

#ifndef RODEO_RENDERER_TEXTURE_H_
#include "renderer\texture.h"
#endif

#ifndef RODEO_CORE_SINGLETON_H
#include "core\singleton.h"
#endif

#ifndef RODEO_CORE_CONSTANTS_H_
#include "core\constants.h"
#endif

#include <vector>

namespace rodeocore
{
class TextureManager : public Singleton<TextureManager>
{
public:
    TextureManager()
    {
        reset();
    }
    
    ~TextureManager()
    {
        clean();
    }

    void bind(ui& tid);

    //Parameter texid is an id of actually loaded texture,
    // from 1 to MAX_TEXTURES
    void load(rodeorenderer::Image* img, const char* filename, ui& tid);

    void load();

    ui loadDDS(const char* filename);

    ui loadTGA(const char* filename);

    rodeorenderer::Texture* getTexture() const { return texture_; }

    static int getTextureCount() { return s_texture_count_; }

private:
    void clean();

    void reset();

//==== MEMBERS ====//
    // Texture object 
    rodeorenderer::Texture* texture_;

    // Counting How many textures are loaded
    static int s_texture_count_;

    // Maximum number of textures to load, this can be changed freely 
    static const ui S_MAX_TEXTURES = 100;

    // Unique Id of a texture
    ui texture_id_[S_MAX_TEXTURES];

    rodeorenderer::Image* image_data_[S_MAX_TEXTURES];

    std::vector<ui> texObj_;
};
}    //end of rodeocore namespace

#endif    //RODEO_CORE_TEXTUREMANAGER_H_